package com.sky.mapper;

import com.sky.annotation.AutoFile;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {
    @AutoFile(OperationType.UPDATE)
    void update(Setmeal setmeal);

    List<SetmealVO> page(Setmeal setmeal);

    @AutoFile(OperationType.INSERT)
    void addSetmeal(Setmeal setmeal);

    @Select("select * from setmeal where id =#{id}")
    Setmeal selectById(Long id);

    @Delete("DELETE from setmeal where id =#{id}")
    void delete(Long id);


    List<SetmealVO> seleteByCategoryId(Setmeal setmeal);

    @Select("select sd.name, sd.copies, d.image, d.description from setmeal_dish sd left join dish d   on d.id =sd.dish_id where sd.setmeal_id=#{id}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);

    Integer countByMap(Map map);
}
